/**
 * Copyright(C) 2012 Luvina
 * TblUserLogicImpl.java, 25-05-2012 NguyenVietDung
 */
package net.luvina.manageuser.logic.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import net.luvina.manageuser.dao.TblUserDao;
import net.luvina.manageuser.dto.UserDetailDto;
import net.luvina.manageuser.hibernate.TblUser;
import net.luvina.manageuser.logic.TblUserLogic;

/**
 * [Description]
 *
 * @author NguyenVietDung
 */
@Service("tblUserLogic")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = { Throwable.class })
public class TblUserLogicImpl implements TblUserLogic {
	@Autowired
	private TblUserDao tblUserDao;

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.TblUserLogic#checkExistedEmail(int,
	 * java.lang.String)
	 */
	@Override
	public boolean checkExistedEmail(int userId, String email) {
		TblUser tblUser = this.tblUserDao.getUserByEmail(userId, email);
		if (tblUser == null) {
			return false;
		}
		return true;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.TblUserLogic#checkExistedLoginName(int,
	 * java.lang.String)
	 */
	@Override
	public boolean checkExistedLoginName(int userId, String loginName) {
		TblUser tblUser = this.tblUserDao.getUserByLoginName(userId, loginName);
		if (tblUser == null) {
			return false;
		}
		return true;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * net.luvina.manageuser.logic.TblUserLogic#createUser(net.luvina.manageuser
	 * .hibernate.TblUser)
	 */
	@Override
	public boolean createUser(TblUser tblUser) {
		// TODO Auto-generated method stub
		return false;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.TblUserLogic#getDetailUserById(int)
	 */
	@Override
	public UserDetailDto getDetailUserById(int userId) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.TblUserLogic#getListUser(int, int, int,
	 * java.lang.String, java.lang.String, java.lang.String, java.lang.String,
	 * java.lang.String)
	 */
	@Override
	public List<UserDetailDto> getListUser(int offset, int limit, int groupId, String fullName, String sortType, String sortByFullName,
			String sortByCodeLevel, String sortByEndDate) {
		// TODO Auto-generated method stub
		return this.tblUserDao.getListUser(offset, limit, groupId, fullName, sortType, sortByFullName, sortByCodeLevel, sortByEndDate);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.TblUserLogic#getTotalRecords(int,
	 * java.lang.String)
	 */
	@Override
	public int getTotalRecords(int groupId, String fullName) {
		// TODO Auto-generated method stub
		return this.tblUserDao.getTotalRecords(groupId, fullName);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.TblUserLogic#getUserById(int)
	 */
	@Override
	public TblUser getUserById(int userId) {
		// TODO Auto-generated method stub
		return null;
	}

}
